<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <!-- 找重复，把一个数组(arr1)里重复的数放到另一个数组(arr2)里，并打印 arr2。
[12, 32, 43, 14, 52, 12, 52, 36, 52]， 打印 [12, 52]
 -->
</head>
<body>
  <script>
    let arr1 = [12,32,43,14,52,12,52,36,52]
    let arr2 = [];
		function useIndexOf() {
        for (let i = 0; i < arr1.length; i++) {
            //遍历到Arr[i]时，若在这个索引i之后都没找到相同数字，则indexOf会返回-1，说明改数字不存在重复
            if (arr1.indexOf(arr1[i], i+1) != -1) {
              arr2.push(arr1[i]);
            }
        }
          return Array.from(new Set(arr2));
    }
    console.log(useIndexOf());

  </script>
</body>
</html>